package com.xt.base.wireless.server;

import java.io.File;
import java.util.Map;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.xt.base.util.SpringUtil;
import com.xt.base.wireless.server.socket.SocketServerListener;
import com.xt.base.wireless.server.udp.UDPServerListener;


/**
 *  <br>
 * <br>
 * 
 * <p>
 * <a href=".java.html"><i>查看源文件</i></a>
 * </p>
 * 
 * @author 杨洪波
 * @create-date:2010-9-7
 */
public class ServerStartQuartz extends QuartzJobBean{

	@SuppressWarnings("unchecked")
	protected void executeInternal(JobExecutionContext arg0)
			throws JobExecutionException {
		Map<String,Object> map = arg0.getMergedJobDataMap();
		
		/*String applicationMobileXml = String.valueOf(map.get("applicationMobileXml"));
		String basePath= this.getClass().getResource("/").getPath();
		if(applicationMobileXml.indexOf("classPath")>=0){
			applicationMobileXml = applicationMobileXml.replace("classPath:", "");
		}else{
			basePath = basePath.substring(0,basePath.indexOf("WEB-INF"));
		}
		
		SpringUtil.getXmlBeanFactory(new File(basePath+applicationMobileXml));*/
		
		if("socket".equals(map.get("socket"))){
			int socketPort = 0 ;
			if(map.get("socketPort")!=null){
				socketPort = Integer.valueOf(String.valueOf(map.get("socketPort")));
			}
			
			new SocketServerListener(socketPort);
		}
		if("UDP".equals(map.get("UDP"))){
			int udpPort = 0 ;
			if(map.get("udpPort")!=null){
				udpPort = Integer.valueOf(String.valueOf(map.get("udpPort")));
			}
			
			new UDPServerListener(udpPort);
		}
		
		
		System.out.println(" --- ServerStartQuartz --");
	}

}
